#!/bin/bash
name=$1
path1=$2
path2=$3
port=$4

if [ ! -n "$name" ]; then
  name="CloudreveV3"
fi

if [ ! -n "$path1" ]; then
  path1="/mnt/user"
fi

if [ ! -n "$path2" ]; then
  path2="/mnt/user/appdata"
fi

if [ ! -n "$port" ]; then
  port="5212"
fi
echo $name
rm -rf ./cloudreve-docker
git clone https://gitee.com/sakina/cloudreve-docker.git
docker stop $name
docker rm $name
docker run -d \
	--name $name \
	-p "${port}:5212" \
	-v "${path2}/${name}:/cloudreve/config" \
	-v "${path1}/NAS:/cloudreve/uploads" \
	-v "${path2}/${name}/db:/cloudreve/db" \
	-v "${path2}/${name}/avater:/cloudreve/avatar" \
xavierniu/cloudreve
